﻿/***********************************************************************
 * <copyright file="Unit.cs" company="BUCA JSC">
 * -->    Copyright (C) statement. All right reserved
 * </copyright>
 * 
 * Created:   LinhMC
 * Email:    linhmc@buca.vn
 * Website:
 * Create Date: Tuesday, October 22, 2013
 * Usage: 
 * 
 * RevisionHistory: 
 * Date    25/10/2013     Author  tuanhm             Description 
 * 
 * ************************************************************************/

using BusinessObjects.BusinessRules;

namespace BusinessObjects.BussinessDictionary
{
    /// <summary>
    ///     Class that holds information about a Unit
    /// </summary>
    public class Unit : BusinessObject
    {
        /// <summary>
        /// </summary>
        public Unit()
        {
            //validateId
            AddRule(new ValidateId("UnitId"));
            //validateRequired
            AddRule(new ValidateRequired("Name"));
            AddRule(new ValidateRequired("IsActive"));
            //validateLength
            AddRule(new ValidateLength("Name", 0, 255));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Unit"/> class.
        /// </summary>
        /// <param name="unitId">The unit identifier.</param>
        /// <param name="parentId">The parent identifier.</param>
        /// <param name="grade">The grade.</param>
        /// <param name="hasParent">if set to <c>true</c> [has parent].</param>
        /// <param name="budgetCode">The budget code.</param>
        /// <param name="code">The code.</param>
        /// <param name="name">The name.</param>
        /// <param name="address">The address.</param>
        /// <param name="isActive">if set to <c>true</c> [is active].</param>
        /// <param name="byManagement">The by management.</param>
        public Unit(int unitId, int parentId, int grade, bool hasParent, string phoneNumber, string code, string name,
                    string address, bool isActive, string byManagement)
            : this()
        {
            UnitId = unitId;
            ParentId = parentId;
            Code = code;
            Name = name;
            Grade = grade;
            IsActive = isActive;
            HasParent = hasParent;
            PhoneNumber = phoneNumber;
            Address = address;
            ByManagement = byManagement;
        }

        /// <summary>
        /// </summary>
        public int UnitId { get; set; }

        /// <summary>
        /// </summary>
        public int? ParentId { get; set; }

        /// <summary>
        /// </summary>
        public int Grade { get; set; }

        /// <summary>
        /// </summary>
        public bool HasParent { get; set; }

        /// <summary>
        /// </summary>
        public string PhoneNumber { get; set; }

        /// <summary>
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// </summary>
        public string Address { get; set; }

        /// <summary>
        /// </summary>
        public bool IsActive { get; set; }

        /// <summary>
        /// Gets or sets the by management.
        /// </summary>
        /// <value>
        /// The by management.
        /// </value>
        public string ByManagement { get; set; }
    }
}